﻿#include "MirItemCell.h"
#include "../MirGraphics/MLibrary.h"
#include "../MirScenes/Dialogs/NPCDialogs.h"
#include "../MirScenes/Dialogs/TrustMerchantDialog.h"
#include "../MirScenes/Dialogs/ItemRentingDialog.h"
#include "../MirObjects/MapObject.h"
#include "../MirScenes/GameScene.h"
#include "../MirScenes/Dialogs/MainDialogs.h"
#include "../MirScenes/Dialogs/TradeDialogs.h"
#include "../MirScenes/Dialogs/MailDialogs.h"
#include "../Forms/Client.CMain.h"
#include "../../Shared/Globals.h"
#include "MirAmountBox.h"
#include "../../Shared/ClientPackets.h"
#include "../MirNetwork/Network.h"
#include "../MirScenes/Dialogs/MountDialog.h"
#include "../MirScenes/Dialogs/FishingDialog.h"
#include "MirMessageBox.h"
#include "../../Shared/Data/Stat.h"
#include "../MirScenes/Dialogs/GuildDialog.h"
#include "../MirSounds/SoundManager.h"
#include "../../Shared/Language.h"
#include "../../Shared/Functions/Functions.h"

using namespace Client::MirGraphics;
using namespace Client::MirNetwork;
using namespace Client::MirObjects;
using namespace Client::MirScenes;
using namespace Client::MirSounds;
using namespace Client::MirScenes::Dialogs;
namespace C = ClientPackets;

namespace Client::MirControls
{

    UserItem *MirItemCell::getItem() const
    {
        if (getGridType() == MirGridType::DropPanel)
        {
            return NPCDropDialog::TargetItem;
        }

        if (getGridType() == MirGridType::TrustMerchant)
        {
            return TrustMerchantDialog::SellItemSlot;
        }

        if (getGridType() == MirGridType::Renting)
        {
            return ItemRentingDialog::RentalItem;
        }

        if (getGridType() == MirGridType::GuestRenting)
        {
            return GuestItemRentingDialog::GuestLoanItem;
        }

        if (!getItemArray().empty() && _itemSlot >= 0 && _itemSlot < getItemArray().size())
        {
            return getItemArray()[_itemSlot];
        }
        return nullptr;
    }

    void MirItemCell::setItem(UserItem *value)
    {
        if (getGridType() == MirGridType::DropPanel)
        {
            NPCDropDialog::TargetItem = value;
        }
        else if (getGridType() == MirGridType::Renting)
        {
            ItemRentingDialog::RentalItem = value;
        }
        else if (getGridType() == MirGridType::TrustMerchant)
        {
            TrustMerchantDialog::SellItemSlot = value;
        }
        else if (getGridType() == MirGridType::GuestRenting)
        {
            GuestItemRentingDialog::GuestLoanItem = value;
        }
        else if (!getItemArray().empty() && _itemSlot >= 0 && _itemSlot < getItemArray().size())
        {
            getItemArray()[_itemSlot] = value;
        }

        SetEffect();
        Redraw();
    }

    UserItem *MirItemCell::getShadowItem() const
    {
        if ((getGridType() == MirGridType::Craft) && _itemSlot >= 0 && _itemSlot < getItemArray().size())
        {
            return CraftDialog::ShadowItems[_itemSlot];
        }

        return nullptr;
    }

    std::vector<UserItem*> MirItemCell::getItemArray() const
    {
        switch (getGridType())
        {
            case MirGridType::Inventory:
                return MapObject::User->Inventory;
            case MirGridType::Equipment:
                return MapObject::User->Equipment;
            case MirGridType::Storage:
                return GameScene::Storage;
            case MirGridType::Inspect:
                return InspectDialog::Items;
            case MirGridType::GuildStorage:
                return GameScene::GuildStorage;
            case MirGridType::Trade:
                return GameScene::getUser()->Trade;
            case MirGridType::GuestTrade:
                return GuestTradeDialog::GuestItems;
            case MirGridType::Mount:
                return MapObject::User->Equipment[static_cast<int>(EquipmentSlot::Mount)]->Slots;
            case MirGridType::Fishing:
                return MapObject::User->Equipment[static_cast<int>(EquipmentSlot::Weapon)]->Slots;
            case MirGridType::QuestInventory:
                return MapObject::User->QuestInventory;
            case MirGridType::AwakenItem:
                return NPCAwakeDialog::Items;
            case MirGridType::Mail:
                return MailComposeParcelDialog::Items;
            case MirGridType::Refine:
                return GameScene::Refine;
            case MirGridType::Craft:
                return CraftDialog::Slots;
            case MirGridType::Socket:
                return GameScene::SelectedItem == nullptr ? std::vector<UserItem*>() : GameScene::SelectedItem->Slots;

            default:
                throw NotImplementedException();
        }

    }

    bool MirItemCell::getBorder() const
    {
        return (GameScene::SelectedCell == this || MouseControl == this || getLocked()) && !(getGridType() == MirGridType::DropPanel || getGridType() == MirGridType::Craft);
    }

    bool MirItemCell::getLocked() const
    {
        return _locked;
    }

    void MirItemCell::setLocked(bool value)
    {
        if (_locked == value)
        {
            return;
        }
        _locked = value;
        Redraw();
    }

    MirGridType MirItemCell::getGridType() const
    {
        return _gridType;
    }

    void MirItemCell::setGridType(MirGridType value)
    {
        if (_gridType == value)
        {
            return;
        }
        _gridType = value;
        OnGridTypeChanged();
    }

    void MirItemCell::OnGridTypeChanged()
    {
        if (GridTypeChanged != nullptr)
        {
            GridTypeChanged::Invoke(this, EventArgs::Empty);
        }
    }

    int MirItemCell::getItemSlot() const
    {
        return _itemSlot;
    }

    void MirItemCell::setItemSlot(int value)
    {
        if (_itemSlot == value)
        {
            return;
        }
        _itemSlot = value;
        OnItemSlotChanged();
    }

    void MirItemCell::OnItemSlotChanged()
    {
        if (ItemSlotChanged != nullptr)
        {
            ItemSlotChanged::Invoke(this, EventArgs::Empty);
        }
    }

    MirLabel *MirItemCell::getCountLabel() const
    {
        return CountLabel;
    }

    void MirItemCell::setCountLabel(MirLabel *value)
    {
        CountLabel = value;
    }

    MirItemCell::MirItemCell()
    {
        Size tempVar(36, 32);
        setSize(&tempVar);
        setGridType(MirGridType::None);
        setDrawImage(false);

        setBorderColour(Color::Lime);

        setBackColour(Color::FromArgb(255, 255, 125, 125));
        setOpacity(0.5F);
        setDrawControlTexture(true);
        setLibrary(Libraries::Items);

    }

    void MirItemCell::SetEffect()
    {
        //put effect stuff here??
    }

    void MirItemCell::OnMouseClick(MouseEventArgs *e)
    {
        if (getLocked())
        {
            return;
        }

        if (GameScene::PickedUpGold || getGridType() == MirGridType::Inspect || getGridType() == MirGridType::QuestInventory)
        {
            return;
        }

        if (GameScene::SelectedCell == nullptr && (getGridType() == MirGridType::Mail))
        {
            return;
        }

        MirImageControl::OnMouseClick(e);

        Redraw();

        switch (e->Button)
        {
            case MouseButtons::Right:
                if (CMain::Ctrl)
                {
                    if (getItem() != nullptr)
                    {
                        OpenItem();
                    }
                    break;
                }

                if (CMain::Shift)
                {
                    if (getItem() != nullptr)
                    {
                        std::string text = StringHelper::formatSimple("<{0}> ", getItem()->getFriendlyName());

                        if (GameScene::Scene->ChatDialog->ChatTextBox->getText().length() + text.length() > Globals::MaxChatLength)
                        {
                            GameScene::Scene->ChatDialog->ReceiveChat("Unable to link item, message exceeds allowed length", ChatType::System);
                            return;
                        }

                        ChatItem *tempVar = new ChatItem();
                        tempVar->UniqueID = getItem()->UniqueID;
                        tempVar->Title = getItem()->getFriendlyName();
                        tempVar->Grid = getGridType();
                        GameScene::Scene->ChatDialog->LinkedItems.push_back(tempVar);
                        GameScene::Scene->ChatDialog->SetChatText(text);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    }

                    break;
                }

                UseItem();
                break;
            case MouseButtons->Left:
                if (getItem() != nullptr && GameScene::SelectedCell == nullptr)
                {
                    PlayItemSound();
                }

                if (CMain::Shift)
                {
                    if (getGridType() == MirGridType::Inventory || getGridType() == MirGridType::Storage)
                    {
                        if (GameScene::SelectedCell == nullptr && getItem() != nullptr)
                        {
                            if (FreeSpace() == 0)
                            {
                                GameScene::Scene->ChatDialog->ReceiveChat("No room to split stack.", ChatType::System);
                                return;
                            }

                            if (getItem()->Count > 1)
                            {
                                MirAmountBox *amountBox = new MirAmountBox("Split Amount:", getItem()->getImage(), static_cast<unsigned int>(getItem()->Count - 1));

                                amountBox->OKButton->Click += [&] (o, a)
                                {
                                    if (amountBox->Amount == 0 || amountBox->Amount >= getItem()->Count)
                                    {
                                        return;
                                    }
                                    C::SplitItem *tempVar2 = new C::SplitItem();
                                    tempVar2->Grid = getGridType();
                                    tempVar2->UniqueID = getItem()->UniqueID;
                                    tempVar2->Count = static_cast<unsigned short>(amountBox->Amount);
                                    Network::Enqueue(tempVar2);
                                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                                };

                                amountBox->Show();

                                delete amountBox;
                            }
                        }
                    }
                }

                //Add support for ALT + click to sell quickly
                else if (CMain::Alt && GameScene::Scene->NPCDropDialog->getVisible() && getGridType() == MirGridType::Inventory) // alt sell/repair
                {
                    MoveItem(); // pickup item
                    GameScene::Scene->NPCDropDialog->ItemCell->OnMouseClick(e); // emulate click to drop control
                    GameScene::Scene->NPCDropDialog->ConfirmButton->OnMouseClick(e); //emulate OK to confirm trade
                }
                //Add support for ALT + click to sell quickly

                else
                {
                    MoveItem();
                }
                break;
        }
    }

    void MirItemCell::OnMouseDoubleClick(MouseEventArgs *e)
    {
        if (getLocked())
        {
            return;
        }

        if (GameScene::PickedUpGold || getGridType() == MirGridType::Inspect || getGridType() == MirGridType::TrustMerchant || getGridType() == MirGridType::Craft)
        {
            return;
        }

        MirImageControl::OnMouseClick(e);

        Redraw();

        GameScene::SelectedCell = nullptr;
        UseItem();
    }

    void MirItemCell::BuyItem()
    {
        if (getItem() == nullptr || getItem()->Price() * GameScene::NPCRate > GameScene::Gold)
        {
            return;
        }

        MirAmountBox *amountBox;
        if (getItem()->Count > 1)
        {
            amountBox = new MirAmountBox("Purchase Amount:", getItem()->getImage(), getItem()->Count);

            amountBox->OKButton->Click += [&] (o, e)
            {
                C::BuyItemBack *tempVar = new C::BuyItemBack();
                tempVar->UniqueID = getItem()->UniqueID;
                tempVar->Count = static_cast<unsigned short>(amountBox->Amount);
                Network::Enqueue(tempVar);
                setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            };
        }
        else
        {
            amountBox = new MirAmountBox("Purchase", getItem()->getImage(), std::string::Format("Value: {0:#,##0} Gold", getItem()->Price()));

            amountBox->OKButton->Click += [&] (o, e)
            {
                C::BuyItemBack *tempVar2 = new C::BuyItemBack();
                tempVar2->UniqueID = getItem()->UniqueID;
                tempVar2->Count = 1;
                Network::Enqueue(tempVar2);
                setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
            };
        }

        amountBox->Show();

        delete amountBox;
    }

    void MirItemCell::OpenItem()
    {
        if ((getGridType() != MirGridType::Equipment && getGridType() != MirGridType::Inventory) || getItem() == nullptr || GameScene::SelectedCell == this)
        {
            return;
        }

        GameScene::Scene->SocketDialog->Show(getGridType(), getItem());
    }

    void MirItemCell::UseItem()
    {
        if (getLocked() || getGridType() == MirGridType::Inspect || getGridType() == MirGridType::TrustMerchant || getGridType() == MirGridType::GuildStorage || getGridType() == MirGridType::Craft)
        {
            return;
        }

        if (MapObject::User->Fishing)
        {
            return;
        }
        if (MapObject::User->RidingMount && getItem()->Info->Type != ItemType::Scroll && getItem()->Info->Type != ItemType::Potion && getItem()->Info->Type != ItemType::Torch)
        {
            return;
        }

        if (getGridType() == MirGridType::BuyBack)
        {
            BuyItem();
            return;
        }

        if (getGridType() == MirGridType::Equipment || getGridType() == MirGridType::Mount || getGridType() == MirGridType::Fishing || getGridType() == MirGridType::Socket)
        {
            RemoveItem();
            return;
        }

        if ((getGridType() != MirGridType::Inventory && getGridType() != MirGridType::Storage) || getItem() == nullptr || !CanUseItem() || GameScene::SelectedCell == this)
        {
            return;
        }

        CharacterDialog *dialog = GameScene::Scene->CharacterDialog;

        if (getItem()->SoulBoundId != -1 && MapObject::User->Id != getItem()->SoulBoundId)
        {
            return;
        }

        switch (getItem()->Info->Type)
        {
            case ItemType::Weapon:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Weapon)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar = new C::EquipItem();
                    tempVar->Grid = getGridType();
                    tempVar->UniqueID = getItem()->UniqueID;
                    tempVar->To = static_cast<int>(EquipmentSlot::Weapon);
                    Network::Enqueue(tempVar);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Weapon)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Armour:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Armour)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar2 = new C::EquipItem();
                    tempVar2->Grid = getGridType();
                    tempVar2->UniqueID = getItem()->UniqueID;
                    tempVar2->To = static_cast<int>(EquipmentSlot::Armour);
                    Network::Enqueue(tempVar2);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Armour)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Helmet:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Helmet)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar3 = new C::EquipItem();
                    tempVar3->Grid = getGridType();
                    tempVar3->UniqueID = getItem()->UniqueID;
                    tempVar3->To = static_cast<int>(EquipmentSlot::Helmet);
                    Network::Enqueue(tempVar3);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Helmet)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Necklace:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Necklace)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar4 = new C::EquipItem();
                    tempVar4->Grid = getGridType();
                    tempVar4->UniqueID = getItem()->UniqueID;
                    tempVar4->To = static_cast<int>(EquipmentSlot::Necklace);
                    Network::Enqueue(tempVar4);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Necklace)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Bracelet:
                if ((dialog->Grid[static_cast<int>(EquipmentSlot::BraceletR)]->getItem() == nullptr || dialog->Grid[static_cast<int>(EquipmentSlot::BraceletR)]->getItem().Info->Type == ItemType::Amulet) && dialog->Grid[static_cast<int>(EquipmentSlot::BraceletR)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar5 = new C::EquipItem();
                    tempVar5->Grid = getGridType();
                    tempVar5->UniqueID = getItem()->UniqueID;
                    tempVar5->To = static_cast<int>(EquipmentSlot::BraceletR);
                    Network::Enqueue(tempVar5);
                    dialog->Grid[static_cast<int>(EquipmentSlot::BraceletR)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                }
                else if (dialog->Grid[static_cast<int>(EquipmentSlot::BraceletL)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar6 = new C::EquipItem();
                    tempVar6->Grid = getGridType();
                    tempVar6->UniqueID = getItem()->UniqueID;
                    tempVar6->To = static_cast<int>(EquipmentSlot::BraceletL);
                    Network::Enqueue(tempVar6);
                    dialog->Grid[static_cast<int>(EquipmentSlot::BraceletL)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Ring:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::RingR)]->getItem() == nullptr && dialog->Grid[static_cast<int>(EquipmentSlot::RingR)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar7 = new C::EquipItem();
                    tempVar7->Grid = getGridType();
                    tempVar7->UniqueID = getItem()->UniqueID;
                    tempVar7->To = static_cast<int>(EquipmentSlot::RingR);
                    Network::Enqueue(tempVar7);
                    dialog->Grid[static_cast<int>(EquipmentSlot::RingR)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
                }
                else if (dialog->Grid[static_cast<int>(EquipmentSlot::RingL)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar8 = new C::EquipItem();
                    tempVar8->Grid = getGridType();
                    tempVar8->UniqueID = getItem()->UniqueID;
                    tempVar8->To = static_cast<int>(EquipmentSlot::RingL);
                    Network::Enqueue(tempVar8);
                    dialog->Grid[static_cast<int>(EquipmentSlot::RingL)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Amulet:
                //if (Item.Info.Shape == 0) return;

                if (dialog->Grid[static_cast<int>(EquipmentSlot::Amulet)]->getItem() != nullptr && getItem()->Info->Type == ItemType::Amulet)
                {
                    if (dialog->Grid[static_cast<int>(EquipmentSlot::Amulet)]->getItem()->Info == getItem()->Info && dialog->Grid[static_cast<int>(EquipmentSlot::Amulet)]->getItem()->Count < dialog->Grid[static_cast<int>(EquipmentSlot::Amulet)]->getItem().Info.StackSize)
                    {
                        C::MergeItem *tempVar9 = new C::MergeItem();
                        tempVar9->GridFrom = getGridType();
                        tempVar9->GridTo = MirGridType::Equipment;
                        tempVar9->IDFrom = getItem()->UniqueID;
                        tempVar9->IDTo = dialog->Grid[static_cast<int>(EquipmentSlot::Amulet)]->getItem().UniqueID;
                        Network::Enqueue(tempVar9);

                        setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
                        return;
                    }
                }

                if (dialog->Grid[static_cast<int>(EquipmentSlot::Amulet)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar10 = new C::EquipItem();
                    tempVar10->Grid = getGridType();
                    tempVar10->UniqueID = getItem()->UniqueID;
                    tempVar10->To = static_cast<int>(EquipmentSlot::Amulet);
                    Network::Enqueue(tempVar10);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Amulet)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Belt:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Belt)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar11 = new C::EquipItem();
                    tempVar11->Grid = getGridType();
                    tempVar11->UniqueID = getItem()->UniqueID;
                    tempVar11->To = static_cast<int>(EquipmentSlot::Belt);
                    Network::Enqueue(tempVar11);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Belt)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Boots:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Boots)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar12 = new C::EquipItem();
                    tempVar12->Grid = getGridType();
                    tempVar12->UniqueID = getItem()->UniqueID;
                    tempVar12->To = static_cast<int>(EquipmentSlot::Boots);
                    Network::Enqueue(tempVar12);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Boots)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Stone:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Stone)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar13 = new C::EquipItem();
                    tempVar13->Grid = getGridType();
                    tempVar13->UniqueID = getItem()->UniqueID;
                    tempVar13->To = static_cast<int>(EquipmentSlot::Stone);
                    Network::Enqueue(tempVar13);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Stone)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Torch:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Torch)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar14 = new C::EquipItem();
                    tempVar14->Grid = getGridType();
                    tempVar14->UniqueID = getItem()->UniqueID;
                    tempVar14->To = static_cast<int>(EquipmentSlot::Torch);
                    Network::Enqueue(tempVar14);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Torch)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Potion:
            case ItemType::Scroll:
            case ItemType::Book:
            case ItemType::Food:
            case ItemType::Script:
            case ItemType::Pets:
            case ItemType::Transform:
            case ItemType::Deco:
                if (CanUseItem() && getGridType() == MirGridType::Inventory)
                {
                    if (CMain::Time < GameScene::UseItemTime)
                    {
                        return;
                    }
                    C::UseItem *tempVar15 = new C::UseItem();
                    tempVar15->UniqueID = getItem()->UniqueID;
                    Network::Enqueue(tempVar15);

                    if (getItem()->Count == 1 && getItemSlot() < 6)
                    {
                        for (int i = GameScene::getUser()->BeltIdx; i < GameScene::getUser()->Inventory.size(); i++)
                        {
                            if (getItemArray()[i] != nullptr && getItemArray()[i]->Info == getItem()->Info)
                            {
                                C::MoveItem *tempVar16 = new C::MoveItem();
                                tempVar16->Grid = MirGridType::Inventory;
                                tempVar16->From = i;
                                tempVar16->To = getItemSlot();
                                Network::Enqueue(tempVar16);
                                GameScene::Scene->InventoryDialog->Grid[i - GameScene::getUser()->BeltIdx]->setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
                                break;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
                            }
                        }
                    }

                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar15' statement was not added since tempVar15 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Mount:
                if (dialog->Grid[static_cast<int>(EquipmentSlot::Mount)]->CanWearItem(getItem()))
                {
                    C::EquipItem *tempVar17 = new C::EquipItem();
                    tempVar17->Grid = getGridType();
                    tempVar17->UniqueID = getItem()->UniqueID;
                    tempVar17->To = static_cast<int>(EquipmentSlot::Mount);
                    Network::Enqueue(tempVar17);
                    dialog->Grid[static_cast<int>(EquipmentSlot::Mount)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar17' statement was not added since tempVar17 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Reins:
            case ItemType::Bells:
            case ItemType::Ribbon:
            case ItemType::Saddle:
            case ItemType::Mask:
            case ItemType::Hook:
            case ItemType::Float:
            case ItemType::Bait:
            case ItemType::Finder:
            case ItemType::Reel:
            case ItemType::Socket:
                UseSlotItem();
                break;
        }

        GameScene::UseItemTime = CMain::Time + 300;
        PlayItemSound();
    }

    void MirItemCell::UseSlotItem()
    {
        MountDialog *mountDialog;
        FishingDialog *fishingDialog;

        if (!CanUseItem())
        {
            return;
        }

        switch (getItem()->Info->Type)
        {
            case ItemType::Socket:
                if (GameScene::SelectedItem != nullptr && !GameScene::SelectedItem->Info->isFishingRod() && GameScene::SelectedItem->Info->Type != ItemType::Mount)
                {
                    switch (getItem()->Info->Shape)
                    {
                        case 1:
                            if (GameScene::SelectedItem->Info->Type != ItemType::Weapon)
                            {
                                return;
                            }
                            break;
                        case 2:
                            if (GameScene::SelectedItem->Info->Type != ItemType::Armour)
                            {
                                return;
                            }
                            break;
                        case 3:
                            if (GameScene::SelectedItem->Info->Type != ItemType::Ring && GameScene::SelectedItem->Info->Type != ItemType::Bracelet && GameScene::SelectedItem->Info->Type != ItemType::Necklace)
                            {
                                return;
                            }
                            break;
                    }

                    MirItemCell *cell = nullptr;
                    for (int i = 0; i < GameScene::Scene->SocketDialog->Grid.size(); i++)
                    {
                        if (!GameScene::Scene->SocketDialog->Grid[i]->getVisible() || GameScene::Scene->SocketDialog->Grid[i]->getItem() != nullptr)
                        {
                            continue;
                        }
                        cell = GameScene::Scene->SocketDialog->Grid[i];
                        break;
                    }

                    if (cell != nullptr && cell->CanWearItem(getItem()))
                    {
                        C::EquipSlotItem *tempVar = new C::EquipSlotItem();
                        tempVar->Grid = getGridType();
                        tempVar->UniqueID = getItem()->UniqueID;
                        tempVar->To = cell->getItemSlot();
                        tempVar->GridTo = MirGridType::Socket;
                        tempVar->ToUniqueID = GameScene::SelectedItem->UniqueID;
                        Network::Enqueue(tempVar);
                        cell->setLocked(true);
                        setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    }
                }
                break;
            case ItemType::Reins:
                mountDialog = GameScene::Scene->MountDialog;
                if (mountDialog->Grid[static_cast<int>(MountSlot::Reins)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Mount)];
                    C::EquipSlotItem *tempVar2 = new C::EquipSlotItem();
                    tempVar2->Grid = getGridType();
                    tempVar2->UniqueID = getItem()->UniqueID;
                    tempVar2->To = static_cast<int>(MountSlot::Reins);
                    tempVar2->GridTo = MirGridType::Mount;
                    tempVar2->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar2);
                    mountDialog->Grid[static_cast<int>(MountSlot::Reins)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Bells:
                mountDialog = GameScene::Scene->MountDialog;
                if (mountDialog->Grid[static_cast<int>(MountSlot::Bells)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Mount)];
                    C::EquipSlotItem *tempVar3 = new C::EquipSlotItem();
                    tempVar3->Grid = getGridType();
                    tempVar3->UniqueID = getItem()->UniqueID;
                    tempVar3->To = static_cast<int>(MountSlot::Bells);
                    tempVar3->GridTo = MirGridType::Mount;
                    tempVar3->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar3);
                    mountDialog->Grid[static_cast<int>(MountSlot::Bells)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Ribbon:
                mountDialog = GameScene::Scene->MountDialog;
                if (mountDialog->Grid[static_cast<int>(MountSlot::Ribbon)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Mount)];
                    C::EquipSlotItem *tempVar4 = new C::EquipSlotItem();
                    tempVar4->Grid = getGridType();
                    tempVar4->UniqueID = getItem()->UniqueID;
                    tempVar4->To = static_cast<int>(MountSlot::Ribbon);
                    tempVar4->GridTo = MirGridType::Mount;
                    tempVar4->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar4);
                    mountDialog->Grid[static_cast<int>(MountSlot::Ribbon)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Saddle:
                mountDialog = GameScene::Scene->MountDialog;
                if (mountDialog->Grid[static_cast<int>(MountSlot::Saddle)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Mount)];
                    C::EquipSlotItem *tempVar5 = new C::EquipSlotItem();
                    tempVar5->Grid = getGridType();
                    tempVar5->UniqueID = getItem()->UniqueID;
                    tempVar5->To = static_cast<int>(MountSlot::Saddle);
                    tempVar5->GridTo = MirGridType::Mount;
                    tempVar5->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar5);
                    mountDialog->Grid[static_cast<int>(MountSlot::Saddle)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Mask:
                mountDialog = GameScene::Scene->MountDialog;
                if (mountDialog->Grid[static_cast<int>(MountSlot::Mask)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Mount)];
                    C::EquipSlotItem *tempVar6 = new C::EquipSlotItem();
                    tempVar6->Grid = getGridType();
                    tempVar6->UniqueID = getItem()->UniqueID;
                    tempVar6->To = static_cast<int>(MountSlot::Mask);
                    tempVar6->GridTo = MirGridType::Mount;
                    tempVar6->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar6);
                    mountDialog->Grid[static_cast<int>(MountSlot::Mask)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Hook:
                fishingDialog = GameScene::Scene->FishingDialog;
                if (fishingDialog->Grid[static_cast<int>(FishingSlot::Hook)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Weapon)];
                    C::EquipSlotItem *tempVar7 = new C::EquipSlotItem();
                    tempVar7->Grid = getGridType();
                    tempVar7->UniqueID = getItem()->UniqueID;
                    tempVar7->To = static_cast<int>(FishingSlot::Hook);
                    tempVar7->GridTo = MirGridType::Fishing;
                    tempVar7->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar7);
                    fishingDialog->Grid[static_cast<int>(FishingSlot::Hook)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Float:
                fishingDialog = GameScene::Scene->FishingDialog;
                if (fishingDialog->Grid[static_cast<int>(FishingSlot::Float)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Weapon)];
                    C::EquipSlotItem *tempVar8 = new C::EquipSlotItem();
                    tempVar8->Grid = getGridType();
                    tempVar8->UniqueID = getItem()->UniqueID;
                    tempVar8->To = static_cast<int>(FishingSlot::Float);
                    tempVar8->GridTo = MirGridType::Fishing;
                    tempVar8->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar8);
                    fishingDialog->Grid[static_cast<int>(FishingSlot::Float)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Bait:
                fishingDialog = GameScene::Scene->FishingDialog;

                if (fishingDialog->Grid[static_cast<int>(FishingSlot::Bait)]->getItem() != nullptr && getItem()->Info->Type == ItemType::Bait)
                {
                    if (fishingDialog->Grid[static_cast<int>(FishingSlot::Bait)]->getItem()->Info == getItem()->Info && fishingDialog->Grid[static_cast<int>(FishingSlot::Bait)]->getItem()->Count < fishingDialog->Grid[static_cast<int>(FishingSlot::Bait)]->getItem().Info.StackSize)
                    {
                        C::MergeItem *tempVar9 = new C::MergeItem();
                        tempVar9->GridFrom = getGridType();
                        tempVar9->GridTo = MirGridType::Fishing;
                        tempVar9->IDFrom = getItem()->UniqueID;
                        tempVar9->IDTo = fishingDialog->Grid[static_cast<int>(FishingSlot::Bait)]->getItem().UniqueID;
                        Network::Enqueue(tempVar9);

                        setLocked(true);
                        GameScene::SelectedCell->setLocked(true);
                        GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
                        return;
                    }
                }

                if (fishingDialog->Grid[static_cast<int>(FishingSlot::Bait)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Weapon)];
                    C::EquipSlotItem *tempVar10 = new C::EquipSlotItem();
                    tempVar10->Grid = getGridType();
                    tempVar10->UniqueID = getItem()->UniqueID;
                    tempVar10->To = static_cast<int>(FishingSlot::Bait);
                    tempVar10->GridTo = MirGridType::Fishing;
                    tempVar10->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar10);
                    fishingDialog->Grid[static_cast<int>(FishingSlot::Bait)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Finder:
                fishingDialog = GameScene::Scene->FishingDialog;
                if (fishingDialog->Grid[static_cast<int>(FishingSlot::Finder)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Weapon)];
                    C::EquipSlotItem *tempVar11 = new C::EquipSlotItem();
                    tempVar11->Grid = getGridType();
                    tempVar11->UniqueID = getItem()->UniqueID;
                    tempVar11->To = static_cast<int>(FishingSlot::Finder);
                    tempVar11->GridTo = MirGridType::Fishing;
                    tempVar11->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar11);
                    fishingDialog->Grid[static_cast<int>(FishingSlot::Finder)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
                }
                break;
            case ItemType::Reel:
                fishingDialog = GameScene::Scene->FishingDialog;
                if (fishingDialog->Grid[static_cast<int>(FishingSlot::Reel)]->CanWearItem(getItem()))
                {
                    auto toItem = MapObject::User->Equipment[static_cast<unsigned char>(EquipmentSlot::Weapon)];
                    C::EquipSlotItem *tempVar12 = new C::EquipSlotItem();
                    tempVar12->Grid = getGridType();
                    tempVar12->UniqueID = getItem()->UniqueID;
                    tempVar12->To = static_cast<int>(FishingSlot::Reel);
                    tempVar12->GridTo = MirGridType::Fishing;
                    tempVar12->ToUniqueID = toItem->UniqueID;
                    Network::Enqueue(tempVar12);
                    fishingDialog->Grid[static_cast<int>(FishingSlot::Reel)]->setLocked(true);
                    setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
                }
                break;
        }
    }

    void MirItemCell::RemoveItem()
    {
        int count = 0;

        for (int i = 0; i < GameScene::getUser()->Inventory.size(); i++)
        {
            MirItemCell *itemCell = i < GameScene::getUser()->BeltIdx ? GameScene::Scene->BeltDialog->Grid[i] : GameScene::Scene->InventoryDialog->Grid[i - GameScene::getUser()->BeltIdx];

            if (itemCell->getItem() == nullptr)
            {
                count++;
            }
        }

        if (getItem() == nullptr || count < 1 || (MapObject::User->RidingMount && getItem()->Info->Type != ItemType::Torch))
        {
            return;
        }

        if (getItem()->Info->StackSize > 1)
        {
            UserItem *item = nullptr;

            for (int i = 0; i < GameScene::getUser()->Inventory.size(); i++)
            {
                MirItemCell *itemCell = i < GameScene::getUser()->BeltIdx ? GameScene::Scene->BeltDialog->Grid[i] : GameScene::Scene->InventoryDialog->Grid[i - GameScene::getUser()->BeltIdx];

                if (itemCell->getItem() == nullptr || itemCell->getItem()->Info != getItem()->Info)
                {
                    continue;
                }

                item = itemCell->getItem();
            }

            if (item != nullptr && ((item->Count + getItem()->Count) <= item->Info->StackSize))
            {
                //Merge.
                C::MergeItem *tempVar = new C::MergeItem();
                tempVar->GridFrom = getGridType();
                tempVar->GridTo = MirGridType::Inventory;
                tempVar->IDFrom = getItem()->UniqueID;
                tempVar->IDTo = item->UniqueID;
                Network::Enqueue(tempVar);

                setLocked(true);

                PlayItemSound();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                return;
            }
        }

        for (int i = 0; i < GameScene::getUser()->Inventory.size(); i++)
        {
            MirItemCell *itemCell;

            if (getItem()->Info->Type == ItemType::Amulet)
            {
                itemCell = i < GameScene::getUser()->BeltIdx ? GameScene::Scene->BeltDialog->Grid[i] : GameScene::Scene->InventoryDialog->Grid[i - GameScene::getUser()->BeltIdx];
            }
            else
            {
                itemCell = i < (GameScene::getUser()->Inventory.size() - GameScene::getUser()->BeltIdx) ? GameScene::Scene->InventoryDialog->Grid[i] : GameScene::Scene->BeltDialog->Grid[i - GameScene::getUser()->Inventory.size()];
            }

            if (itemCell->getItem() != nullptr)
            {
                continue;
            }

            if (getGridType() != MirGridType::Equipment)
            {
                unsigned long long fromID;

                if (getGridType() == MirGridType::Fishing)
                {
                    if (GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::Weapon)]->getItem() == nullptr)
                    {
                        return;
                    }

                    fromID = GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::Weapon)]->getItem().UniqueID;
                }
                else if (getGridType() == MirGridType::Mount)
                {
                    if (GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::Mount)]->getItem() == nullptr)
                    {
                        return;
                    }

                    fromID = GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::Mount)]->getItem().UniqueID;
                }
                else
                {
                    if (GameScene::SelectedItem == nullptr)
                    {
                        return;
                    }

                    fromID = GameScene::SelectedItem->UniqueID;
                }

                C::RemoveSlotItem *tempVar2 = new C::RemoveSlotItem();
                tempVar2->Grid = getGridType();
                tempVar2->UniqueID = getItem()->UniqueID;
                tempVar2->To = itemCell->getItemSlot();
                tempVar2->GridTo = MirGridType::Inventory;
                tempVar2->FromUniqueID = fromID;
                Network::Enqueue(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
            }
            else
            {
                C::RemoveItem *tempVar3 = new C::RemoveItem();
                tempVar3->Grid = MirGridType::Inventory;
                tempVar3->UniqueID = getItem()->UniqueID;
                tempVar3->To = itemCell->getItemSlot();
                Network::Enqueue(tempVar3);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
            }

            setLocked(true);

            PlayItemSound();
            break;
        }

    }

    void MirItemCell::MoveItem()
    {
        if (getGridType() == MirGridType::BuyBack || getGridType() == MirGridType::DropPanel || getGridType() == MirGridType::Inspect || getGridType() == MirGridType::TrustMerchant || getGridType() == MirGridType::Craft)
        {
            return;
        }

        if (GameScene::SelectedCell != nullptr)
        {
            if (GameScene::SelectedCell->getItem() == nullptr || GameScene::SelectedCell == this)
            {
                GameScene::SelectedCell = nullptr;
                return;
            }

            switch (getGridType())
            {
                #pragma region To Inventory
                case MirGridType::Inventory: // To Inventory
                    switch (GameScene::SelectedCell->getGridType())
                    {
                        #pragma region From Inventory
                        case MirGridType::Inventory: //From Invenotry
                            if (getItem() != nullptr)
                            {
                                if (CMain::Ctrl)
                                {
                                    MirMessageBox *messageBox = new MirMessageBox("Do you want to try and combine these items?", MirMessageBoxButtons::YesNo);
                                    messageBox->YesButton->Click += [&] (o, e)
                                    {
                                        //Combine
                                        C::CombineItem *tempVar = new C::CombineItem();
                                        tempVar->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                        tempVar->IDTo = getItem()->UniqueID;
                                        Network::Enqueue(tempVar);
                                        setLocked(true);
                                        GameScene::SelectedCell->setLocked(true);
                                        GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                                    };

                                    messageBox->Show();

                                    delete messageBox;
                                    return;
                                }

                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    //Merge
                                    C::MergeItem *tempVar2 = new C::MergeItem();
                                    tempVar2->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar2->GridTo = getGridType();
                                    tempVar2->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar2->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar2);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            C::MoveItem *tempVar3 = new C::MoveItem();
                            tempVar3->Grid = getGridType();
                            tempVar3->From = GameScene::SelectedCell->getItemSlot();
                            tempVar3->To = getItemSlot();
                            Network::Enqueue(tempVar3);

                            setLocked(true);
                            GameScene::SelectedCell->setLocked(true);
                            GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                            return;
                        #pragma endregion
                        #pragma region From Equipment
                        case MirGridType::Equipment: //From Equipment
                            if (getItem() != nullptr && GameScene::SelectedCell->getItem()->Info->Type == ItemType::Amulet)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar4 = new C::MergeItem();
                                    tempVar4->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar4->GridTo = getGridType();
                                    tempVar4->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar4->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar4);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            if (!CanRemoveItem(GameScene::SelectedCell->getItem()))
                            {
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }
                            if (getItem() == nullptr)
                            {
                                C::RemoveItem *tempVar5 = new C::RemoveItem();
                                tempVar5->Grid = getGridType();
                                tempVar5->UniqueID = GameScene::SelectedCell->getItem()->UniqueID;
                                tempVar5->To = getItemSlot();
                                Network::Enqueue(tempVar5);

                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            for (int x = 6; x < getItemArray().size(); x++)
                            {
                                if (getItemArray()[x] == nullptr)
                                {
                                    C::RemoveItem *tempVar6 = new C::RemoveItem();
                                    tempVar6->Grid = getGridType();
                                    tempVar6->UniqueID = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar6->To = x;
                                    Network::Enqueue(tempVar6);

                                    MirItemCell *temp = x < GameScene::getUser()->BeltIdx ? GameScene::Scene->BeltDialog->Grid[x] : GameScene::Scene->InventoryDialog->Grid[x - GameScene::getUser()->BeltIdx];

                                    if (temp != nullptr)
                                    {
                                        temp->setLocked(true);
                                    }
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }
                            break;
                        #pragma endregion
                        #pragma region From Storage
                        case MirGridType::Storage: //From Storage
                            if (getItem() != nullptr && GameScene::SelectedCell->getItem()->Info->Type == ItemType::Amulet)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar7 = new C::MergeItem();
                                    tempVar7->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar7->GridTo = getGridType();
                                    tempVar7->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar7->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar7);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            if (GameScene::SelectedCell->getItem()->getWeight() + MapObject::User->CurrentBagWeight > MapObject::User->Stats[Stat::BagWeight])
                            {
                                GameScene::Scene->ChatDialog->ReceiveChat("Too heavy to get back.", ChatType::System);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar8 = new C::MergeItem();
                                    tempVar8->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar8->GridTo = getGridType();
                                    tempVar8->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar8->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar8);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }


                            if (getItem() == nullptr)
                            {
                                C::TakeBackItem *tempVar9 = new C::TakeBackItem();
                                tempVar9->From = GameScene::SelectedCell->getItemSlot();
                                tempVar9->To = getItemSlot();
                                Network::Enqueue(tempVar9);

                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            for (int x = 6; x < getItemArray().size(); x++)
                            {
                                if (getItemArray()[x] == nullptr)
                                {
                                    C::TakeBackItem *tempVar10 = new C::TakeBackItem();
                                    tempVar10->From = GameScene::SelectedCell->getItemSlot();
                                    tempVar10->To = x;
                                    Network::Enqueue(tempVar10);

                                    MirItemCell *temp = x < GameScene::getUser()->BeltIdx ? GameScene::Scene->BeltDialog->Grid[x] : GameScene::Scene->InventoryDialog->Grid[x - GameScene::getUser()->BeltIdx];

                                    if (temp != nullptr)
                                    {
                                        temp->setLocked(true);
                                    }
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }
                            break;
                        #pragma endregion
                        #pragma region From Guild Storage
                        case MirGridType::GuildStorage:
                            if (getItem() != nullptr)
                            {
                                GameScene::Scene->ChatDialog->ReceiveChat("You cannot swap items.", ChatType::System);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }
                            if (!GuildDialog::MyOptions::HasFlag(GuildRankOptions::CanRetrieveItem))
                            {
                                GameScene::Scene->ChatDialog->ReceiveChat("Insufficient rights to retrieve items.", ChatType::System);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }
                            C::GuildStorageItemChange *tempVar11 = new C::GuildStorageItemChange();
                            tempVar11->Type = 1;
                            tempVar11->From = GameScene::SelectedCell->getItemSlot();
                            tempVar11->To = getItemSlot();
                            Network::Enqueue(tempVar11);
                            setLocked(true);
                            GameScene::SelectedCell->setLocked(true);
                            GameScene::SelectedCell = nullptr;
                            break;
                        #pragma endregion
                        #pragma region From Trade
                        case MirGridType::Trade: //From Trade
                            if (getItem() != nullptr && GameScene::SelectedCell->getItem()->Info->Type == ItemType::Amulet)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar12 = new C::MergeItem();
                                    tempVar12->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar12->GridTo = getGridType();
                                    tempVar12->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar12->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar12);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            if (GameScene::SelectedCell->getItem()->getWeight() + MapObject::User->CurrentBagWeight > MapObject::User->Stats[Stat::BagWeight])
                            {
                                GameScene::Scene->ChatDialog->ReceiveChat("Too heavy to get back.", ChatType::System);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar13 = new C::MergeItem();
                                    tempVar13->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar13->GridTo = getGridType();
                                    tempVar13->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar13->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar13);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }


                            if (getItem() == nullptr)
                            {
                                C::RetrieveTradeItem *tempVar14 = new C::RetrieveTradeItem();
                                tempVar14->From = GameScene::SelectedCell->getItemSlot();
                                tempVar14->To = getItemSlot();
                                Network::Enqueue(tempVar14);

                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            for (int x = 6; x < getItemArray().size(); x++)
                            {
                                if (getItemArray()[x] == nullptr)
                                {
                                    C::RetrieveTradeItem *tempVar15 = new C::RetrieveTradeItem();
                                    tempVar15->From = GameScene::SelectedCell->getItemSlot();
                                    tempVar15->To = x;
                                    Network::Enqueue(tempVar15);

                                    MirItemCell *temp = x < GameScene::getUser()->BeltIdx ? GameScene::Scene->BeltDialog->Grid[x] : GameScene::Scene->InventoryDialog->Grid[x - GameScene::getUser()->BeltIdx];

                                    if (temp != nullptr)
                                    {
                                        temp->setLocked(true);
                                    }
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar15' statement was not added since tempVar15 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }
                            break;
                        #pragma endregion
                        #pragma region From AwakenItem
                        case MirGridType::AwakenItem: //From AwakenItem
                            C::MoveItem *tempVar16 = new C::MoveItem();
                            tempVar16->Grid = getGridType();
                            tempVar16->From = NPCAwakeDialog::ItemsIdx[GameScene::SelectedCell->getItemSlot()];
                            tempVar16->To = NPCAwakeDialog::ItemsIdx[GameScene::SelectedCell->getItemSlot()];
                            Network::Enqueue(tempVar16);
                            GameScene::SelectedCell->setLocked(false);
                            GameScene::SelectedCell->setItem(nullptr);
                            NPCAwakeDialog::ItemsIdx[GameScene::SelectedCell->getItemSlot()] = 0;

                            if (GameScene::SelectedCell->getItemSlot() == 0)
                            {
                                GameScene::Scene->NPCAwakeDialog->ItemCell_Click();
                            }
                            GameScene::SelectedCell = nullptr;
                            break;
                         #pragma endregion

                        #pragma region From Refine
                        case MirGridType::Refine: //From AwakenItem
                            if (getItem() != nullptr && GameScene::SelectedCell->getItem()->Info->Type == ItemType::Amulet)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar17 = new C::MergeItem();
                                    tempVar17->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar17->GridTo = getGridType();
                                    tempVar17->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar17->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar17);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar17' statement was not added since tempVar17 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            if (GameScene::SelectedCell->getItem()->getWeight() + MapObject::User->CurrentBagWeight > MapObject::User->Stats[Stat::BagWeight])
                            {
                                GameScene::Scene->ChatDialog->ReceiveChat("Too heavy to get back.", ChatType::System);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar18 = new C::MergeItem();
                                    tempVar18->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar18->GridTo = getGridType();
                                    tempVar18->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar18->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar18);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }


                            if (getItem() == nullptr)
                            {
                                C::RetrieveRefineItem *tempVar19 = new C::RetrieveRefineItem();
                                tempVar19->From = GameScene::SelectedCell->getItemSlot();
                                tempVar19->To = getItemSlot();
                                Network::Enqueue(tempVar19);

                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar19' statement was not added since tempVar19 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            for (int x = 6; x < getItemArray().size(); x++)
                            {
                                if (getItemArray()[x] == nullptr)
                                {
                                    C::RetrieveRefineItem *tempVar20 = new C::RetrieveRefineItem();
                                    tempVar20->From = GameScene::SelectedCell->getItemSlot();
                                    tempVar20->To = x;
                                    Network::Enqueue(tempVar20);

                                    MirItemCell *temp = x < GameScene::getUser()->BeltIdx ? GameScene::Scene->BeltDialog->Grid[x] : GameScene::Scene->InventoryDialog->Grid[x - GameScene::getUser()->BeltIdx];

                                    if (temp != nullptr)
                                    {
                                        temp->setLocked(true);
                                    }
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar20' statement was not added since tempVar20 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }
                            break;
                        #pragma endregion

                        #pragma region From Item Renting Dialog

                        case MirGridType::Renting:
                            if (GameScene::getUser()->RentalItemLocked)
                            {
                                GameScene::Scene->ChatDialog->ReceiveChat("Unable to remove locked item, cancel item rental and try again.", ChatType::System);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            if (GameScene::SelectedCell->getItem()->getWeight() + MapObject::User->CurrentBagWeight > MapObject::User->Stats[Stat::BagWeight])
                            {
                                GameScene::Scene->ChatDialog->ReceiveChat("Too heavy to get back.", ChatType::System);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            if (getItem() == nullptr)
                            {
                                C::RetrieveRentalItem *tempVar21 = new C::RetrieveRentalItem();
                                tempVar21->From = GameScene::SelectedCell->getItemSlot();
                                tempVar21->To = getItemSlot();
                                Network::Enqueue(tempVar21);

                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar21' statement was not added since tempVar21 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            break;
                            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar16' statement was not added since tempVar16 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    }
                    break;
                #pragma endregion
                #pragma region To Equipment
                case MirGridType::Equipment: //To Equipment

                    if (GameScene::SelectedCell->getGridType() != MirGridType::Inventory && GameScene::SelectedCell->getGridType() != MirGridType::Storage)
                    {
                        return;
                    }


                    if (getItem() != nullptr && GameScene::SelectedCell->getItem()->Info->Type == ItemType::Amulet)
                    {
                        if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                        {
                            C::MergeItem *tempVar22 = new C::MergeItem();
                            tempVar22->GridFrom = GameScene::SelectedCell->getGridType();
                            tempVar22->GridTo = getGridType();
                            tempVar22->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                            tempVar22->IDTo = getItem()->UniqueID;
                            Network::Enqueue(tempVar22);

                            setLocked(true);
                            GameScene::SelectedCell->setLocked(true);
                            GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar22' statement was not added since tempVar22 was passed to a method or constructor. Handle memory management manually.
                            return;
                        }
                    }

                    if (CorrectSlot(GameScene::SelectedCell->getItem()))
                    {
                        if (CanWearItem(GameScene::SelectedCell->getItem()))
                        {
                            C::EquipItem *tempVar23 = new C::EquipItem();
                            tempVar23->Grid = GameScene::SelectedCell->getGridType();
                            tempVar23->UniqueID = GameScene::SelectedCell->getItem()->UniqueID;
                            tempVar23->To = getItemSlot();
                            Network::Enqueue(tempVar23);
                            setLocked(true);
                            GameScene::SelectedCell->setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar23' statement was not added since tempVar23 was passed to a method or constructor. Handle memory management manually.
                        }
                        GameScene::SelectedCell = nullptr;
                    }
                    return;
                #pragma endregion
                #pragma region To Storage
                case MirGridType::Storage: //To Storage
                    switch (GameScene::SelectedCell->getGridType())
                    {
                        #pragma region From Inventory
                        case MirGridType::Inventory: //From Invenotry
                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar24 = new C::MergeItem();
                                    tempVar24->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar24->GridTo = getGridType();
                                    tempVar24->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar24->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar24);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar24' statement was not added since tempVar24 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }


                            if (getItemArray()[getItemSlot()] == nullptr)
                            {
                                C::StoreItem *tempVar25 = new C::StoreItem();
                                tempVar25->From = GameScene::SelectedCell->getItemSlot();
                                tempVar25->To = getItemSlot();
                                Network::Enqueue(tempVar25);
                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar25' statement was not added since tempVar25 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            for (int x = 0; x < getItemArray().size(); x++)
                            {
                                if (getItemArray()[x] == nullptr)
                                {
                                    C::StoreItem *tempVar26 = new C::StoreItem();
                                    tempVar26->From = GameScene::SelectedCell->getItemSlot();
                                    tempVar26->To = x;
                                    Network::Enqueue(tempVar26);

                                    MirItemCell *temp = GameScene::Scene->StorageDialog->Grid[x];
                                    if (temp != nullptr)
                                    {
                                        temp->setLocked(true);
                                    }
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar26' statement was not added since tempVar26 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }
                            break;
                        #pragma endregion
                        #pragma region From Equipment
                        case MirGridType::Equipment: //From Equipment
                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    //Merge.
                                    C::MergeItem *tempVar27 = new C::MergeItem();
                                    tempVar27->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar27->GridTo = getGridType();
                                    tempVar27->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar27->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar27);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar27' statement was not added since tempVar27 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            if (!CanRemoveItem(GameScene::SelectedCell->getItem()))
                            {
                                GameScene::SelectedCell = nullptr;
                                return;
                            }

                            if (getItem() == nullptr)
                            {
                                C::RemoveItem *tempVar28 = new C::RemoveItem();
                                tempVar28->Grid = getGridType();
                                tempVar28->UniqueID = GameScene::SelectedCell->getItem()->UniqueID;
                                tempVar28->To = getItemSlot();
                                Network::Enqueue(tempVar28);

                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar28' statement was not added since tempVar28 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            for (int x = 0; x < getItemArray().size(); x++)
                            {
                                if (getItemArray()[x] == nullptr)
                                {
                                    C::RemoveItem *tempVar29 = new C::RemoveItem();
                                    tempVar29->Grid = getGridType();
                                    tempVar29->UniqueID = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar29->To = x;
                                    Network::Enqueue(tempVar29);

                                    MirItemCell *temp = GameScene::Scene->StorageDialog->Grid[x];
                                    if (temp != nullptr)
                                    {
                                        temp->setLocked(true);
                                    }
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar29' statement was not added since tempVar29 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }
                            break;
                        #pragma endregion
                        #pragma region From Storage
                        case MirGridType::Storage:
                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    //Merge.
                                    C::MergeItem *tempVar30 = new C::MergeItem();
                                    tempVar30->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar30->GridTo = getGridType();
                                    tempVar30->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar30->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar30);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar30' statement was not added since tempVar30 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            C::MoveItem *tempVar31 = new C::MoveItem();
                            tempVar31->Grid = getGridType();
                            tempVar31->From = GameScene::SelectedCell->getItemSlot();
                            tempVar31->To = getItemSlot();
                            Network::Enqueue(tempVar31);
                            setLocked(true);
                            GameScene::SelectedCell->setLocked(true);
                            GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar31' statement was not added since tempVar31 was passed to a method or constructor. Handle memory management manually.
                            return;
                        #pragma endregion

                    }
                    break;

                #pragma endregion
                #pragma region To guild storage
                case MirGridType::GuildStorage: //To Guild Storage
                    switch (GameScene::SelectedCell->getGridType())
                    {
                        case MirGridType::GuildStorage: //From Guild Storage
                            if (GameScene::SelectedCell->getGridType() == MirGridType::GuildStorage)
                            {
                                if (!GuildDialog::MyOptions::HasFlag(GuildRankOptions::CanStoreItem))
                                {
                                    GameScene::Scene->ChatDialog->ReceiveChat("Insufficient rights to store items.", ChatType::System);
                                    return;
                                }

                                //if (ItemArray[ItemSlot] == null)
                                //{
                                    C::GuildStorageItemChange *tempVar32 = new C::GuildStorageItemChange();
                                    tempVar32->Type = 2;
                                    tempVar32->From = GameScene::SelectedCell->getItemSlot();
                                    tempVar32->To = getItemSlot();
                                    Network::Enqueue(tempVar32);
                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar32' statement was not added since tempVar32 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                //}
                            }
                            return;

                        case MirGridType::Inventory:

                            if (GameScene::SelectedCell->getGridType() == MirGridType::Inventory)
                            {
                                if (getItem() != nullptr)
                                {
                                    GameScene::Scene->ChatDialog->ReceiveChat("You cannot swap items.", ChatType::System);
                                    return;
                                }
                                if (!GuildDialog::MyOptions::HasFlag(GuildRankOptions::CanStoreItem))
                                {
                                    GameScene::Scene->ChatDialog->ReceiveChat("Insufficient rights to store items.", ChatType::System);
                                    return;
                                }
                                if (getItemArray()[getItemSlot()] == nullptr)
                                {
                                    C::GuildStorageItemChange *tempVar33 = new C::GuildStorageItemChange();
                                    tempVar33->Type = 0;
                                    tempVar33->From = GameScene::SelectedCell->getItemSlot();
                                    tempVar33->To = getItemSlot();
                                    Network::Enqueue(tempVar33);
                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar33' statement was not added since tempVar33 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }
                            return;
                    }
                    break;
                #pragma endregion
                #pragma region To Trade

                case MirGridType::Trade:
                    if (getItem() != nullptr && getItem()->Info->Bind::HasFlag(BindMode::DontTrade))
                    {
                        return;
                    }

                    switch (GameScene::SelectedCell->getGridType())
                    {
                        #pragma region From Trade
                        case MirGridType::Trade: //From Trade
                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    //Merge.
                                    C::MergeItem *tempVar34 = new C::MergeItem();
                                    tempVar34->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar34->GridTo = getGridType();
                                    tempVar34->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar34->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar34);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar34' statement was not added since tempVar34 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            C::MoveItem *tempVar35 = new C::MoveItem();
                            tempVar35->Grid = getGridType();
                            tempVar35->From = GameScene::SelectedCell->getItemSlot();
                            tempVar35->To = getItemSlot();
                            Network::Enqueue(tempVar35);

                            setLocked(true);
                            GameScene::SelectedCell->setLocked(true);
                            GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar35' statement was not added since tempVar35 was passed to a method or constructor. Handle memory management manually.
                            return;
                        #pragma endregion

                        #pragma region From Inventory
                        case MirGridType::Inventory: //From Inventory
                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar36 = new C::MergeItem();
                                    tempVar36->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar36->GridTo = getGridType();
                                    tempVar36->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar36->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar36);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar36' statement was not added since tempVar36 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar35' statement was not added since tempVar35 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }


                            if (getItemArray()[getItemSlot()] == nullptr)
                            {
                                C::DepositTradeItem *tempVar37 = new C::DepositTradeItem();
                                tempVar37->From = GameScene::SelectedCell->getItemSlot();
                                tempVar37->To = getItemSlot();
                                Network::Enqueue(tempVar37);
                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar37' statement was not added since tempVar37 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar35' statement was not added since tempVar35 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            for (int x = 0; x < getItemArray().size(); x++)
                            {
                                if (getItemArray()[x] == nullptr)
                                {
                                    C::DepositTradeItem *tempVar38 = new C::DepositTradeItem();
                                    tempVar38->From = GameScene::SelectedCell->getItemSlot();
                                    tempVar38->To = x;
                                    Network::Enqueue(tempVar38);

                                    MirItemCell *temp = GameScene::Scene->TradeDialog->Grid[x];
                                    if (temp != nullptr)
                                    {
                                        temp->setLocked(true);
                                    }
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar38' statement was not added since tempVar38 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar35' statement was not added since tempVar35 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }
                            break;
                        #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar35' statement was not added since tempVar35 was passed to a method or constructor. Handle memory management manually.
                    }
                    break;

                #pragma endregion

                #pragma region To Refine 

                case MirGridType::Refine:

                    switch (GameScene::SelectedCell->getGridType())
                    {
                        #pragma region From Refine
                        case MirGridType::Refine: //From Refine
                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    //Merge.
                                    C::MergeItem *tempVar39 = new C::MergeItem();
                                    tempVar39->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar39->GridTo = getGridType();
                                    tempVar39->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar39->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar39);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar39' statement was not added since tempVar39 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            C::MoveItem *tempVar40 = new C::MoveItem();
                            tempVar40->Grid = getGridType();
                            tempVar40->From = GameScene::SelectedCell->getItemSlot();
                            tempVar40->To = getItemSlot();
                            Network::Enqueue(tempVar40);
                            setLocked(true);
                            GameScene::SelectedCell->setLocked(true);
                            GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar40' statement was not added since tempVar40 was passed to a method or constructor. Handle memory management manually.
                            return;
                        #pragma endregion

                        #pragma region From Inventory
                        case MirGridType::Inventory: //From Inventory
                            if (getItem() != nullptr)
                            {
                                if (GameScene::SelectedCell->getItem()->Info == getItem()->Info && getItem()->Count < getItem()->Info->StackSize)
                                {
                                    C::MergeItem *tempVar41 = new C::MergeItem();
                                    tempVar41->GridFrom = GameScene::SelectedCell->getGridType();
                                    tempVar41->GridTo = getGridType();
                                    tempVar41->IDFrom = GameScene::SelectedCell->getItem()->UniqueID;
                                    tempVar41->IDTo = getItem()->UniqueID;
                                    Network::Enqueue(tempVar41);

                                    setLocked(true);
                                    GameScene::SelectedCell->setLocked(true);
                                    GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar41' statement was not added since tempVar41 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar40' statement was not added since tempVar40 was passed to a method or constructor. Handle memory management manually.
                                    return;
                                }
                            }

                            C::DepositRefineItem *tempVar42 = new C::DepositRefineItem();
                            tempVar42->From = GameScene::SelectedCell->getItemSlot();
                            tempVar42->To = getItemSlot();
                            Network::Enqueue(tempVar42);
                            setLocked(true);
                            GameScene::SelectedCell->setLocked(true);
                            GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar42' statement was not added since tempVar42 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar40' statement was not added since tempVar40 was passed to a method or constructor. Handle memory management manually.
                            return;
                        #pragma endregion
                    }
                    break;

                #pragma endregion

                #pragma region To Item Renting Dialog

                case MirGridType::Renting:
                    switch (GameScene::SelectedCell->getGridType())
                    {
                        case MirGridType::Inventory:

                            if (getItem() == nullptr)
                            {
                                C::DepositRentalItem *tempVar43 = new C::DepositRentalItem();
                                tempVar43->From = GameScene::SelectedCell->getItemSlot();
                                tempVar43->To = getItemSlot();
                                Network::Enqueue(tempVar43);
                                setLocked(true);
                                GameScene::SelectedCell->setLocked(true);
                                GameScene::SelectedCell = nullptr;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar43' statement was not added since tempVar43 was passed to a method or constructor. Handle memory management manually.
                                return;
                            }

                            break;
                    }

                    break;

                #pragma endregion

                #pragma region To Awakening
                case MirGridType::AwakenItem:
                {
                        int errorCode = 0;

                        if (GameScene::SelectedCell->getGridType() != MirGridType::Inventory && _itemSlot < 1)
                        {
                            return;
                        }

                        switch (_itemSlot)
                        {
                                //baseitem
                            case 0:
                            {
                                    if ((GameScene::SelectedCell->getItem()->Info->Type == ItemType::Weapon || GameScene::SelectedCell->getItem()->Info->Type == ItemType::Helmet || GameScene::SelectedCell->getItem()->Info->Type == ItemType::Armour) && GameScene::SelectedCell->getItem()->Info->Grade != ItemGrade::None && _itemSlot == 0)
                                    {
                                        if (getItem() == nullptr)
                                        {
                                            setItem(GameScene::SelectedCell->getItem());
                                            GameScene::SelectedCell->setLocked(true);
                                            NPCAwakeDialog::ItemsIdx[_itemSlot] = GameScene::SelectedCell->_itemSlot;
                                        }
                                        else
                                        {
                                            C::AwakeningLockedItem *tempVar44 = new C::AwakeningLockedItem();
                                            tempVar44->UniqueID = getItem()->UniqueID;
                                            tempVar44->Locked = false;
                                            Network::Enqueue(tempVar44);

                                            setItem(GameScene::SelectedCell->getItem());
                                            GameScene::SelectedCell->setLocked(true);
                                            NPCAwakeDialog::ItemsIdx[_itemSlot] = GameScene::SelectedCell->_itemSlot;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar44' statement was not added since tempVar44 was passed to a method or constructor. Handle memory management manually.
                                        }
                                        GameScene::Scene->NPCAwakeDialog->ItemCell_Click();
                                        GameScene::Scene->NPCAwakeDialog->OnAwakeTypeSelect(0);
                                    }
                                    else
                                    {
                                        errorCode = -2;
                                    }
                            }
                                break;
                                //view materials
                            case 1:
                            case 2:
                                break;
                                //materials
                            case 3:
                            case 4:
                            {
                                    switch (GameScene::SelectedCell->getGridType())
                                    {
                                        case MirGridType::Inventory:
                                        {
                                                if (GameScene::SelectedCell->getItem()->Info->Type == ItemType::Awakening && GameScene::SelectedCell->getItem()->Info->Shape < 200 && NPCAwakeDialog::ItemsIdx[_itemSlot] == 0)
                                                {
                                                    setItem(GameScene::SelectedCell->getItem());
                                                    GameScene::SelectedCell->setLocked(true);
                                                    NPCAwakeDialog::ItemsIdx[_itemSlot] = GameScene::SelectedCell->_itemSlot;
                                                }
                                                else
                                                {
                                                    errorCode = -2;
                                                }
                                        }
                                            break;
                                        case MirGridType::AwakenItem:
                                        {
                                                if (GameScene::SelectedCell->getItemSlot() == getItemSlot() || GameScene::SelectedCell->getItemSlot() == 0)
                                                {
                                                    setLocked(false);
                                                    GameScene::SelectedCell = nullptr;
                                                }
                                                else
                                                {
                                                    GameScene::SelectedCell->setLocked(false);
                                                    setLocked(false);

                                                    int beforeIdx = NPCAwakeDialog::ItemsIdx[GameScene::SelectedCell->_itemSlot];
                                                    NPCAwakeDialog::ItemsIdx[GameScene::SelectedCell->_itemSlot] = NPCAwakeDialog::ItemsIdx[_itemSlot];
                                                    NPCAwakeDialog::ItemsIdx[_itemSlot] = beforeIdx;

                                                    UserItem *item = GameScene::SelectedCell->getItem();
                                                    GameScene::SelectedCell->setItem(getItem());
                                                    setItem(item);
                                                    GameScene::SelectedCell = nullptr;
                                                }
                                        }
                                            break;
                                    }

                            }
                                break;
                                //SuccessRateUpItem or RandomValueUpItem or CancelDestroyedItem etc.
                                //AllCashItem Korea Server Not Implementation.
                            case 5:
                            case 6:
                                if (GameScene::SelectedCell->getItem()->Info->Type == ItemType::Awakening && GameScene::SelectedCell->getItem()->Info->Shape == 200)
                                {
                                    setItem(GameScene::SelectedCell->getItem());
                                    GameScene::SelectedCell->setLocked(true);
                                    NPCAwakeDialog::ItemsIdx[_itemSlot] = GameScene::SelectedCell->_itemSlot;
                                }
                                else
                                {
                                    errorCode = -2;
                                }
                                break;
                            default:
                                break;
                        }

                        GameScene::SelectedCell = nullptr;
                        MirMessageBox *messageBox;

                        switch (errorCode)
                        {
                            //case -1:
                            //    messageBox = new MirMessageBox("Item must be in your inventory.", MirMessageBoxButtons.OK);
                            //    messageBox.Show();
                            //    break;
                            case -2:
                                //messageBox = new MirMessageBox("Cannot awaken this item.", MirMessageBoxButtons.OK);
                                //messageBox.Show();
                                break;
                        }
                }
                    return;
                #pragma endregion
                #pragma region To Mail
                case MirGridType::Mail: //To Mail
                    if (GameScene::SelectedCell->getGridType() == MirGridType::Inventory)
                    {
                        if (getItem() != nullptr)
                        {
                            GameScene::Scene->ChatDialog->ReceiveChat("You cannot swap items.", ChatType::System);
                            return;
                        }

                        if (GameScene::SelectedCell->getItem()->Info->Bind::HasFlag(BindMode::DontTrade))
                        {
                            GameScene::Scene->ChatDialog->ReceiveChat("You cannot mail this item.", ChatType::System);
                            return;
                        }

                        if (getItemArray()[getItemSlot()] == nullptr)
                        {
                            setItem(GameScene::SelectedCell->getItem());
                            GameScene::SelectedCell->setLocked(true);
                            MailComposeParcelDialog::ItemsIdx[_itemSlot] = GameScene::SelectedCell->getItem()->UniqueID;
                            GameScene::SelectedCell = nullptr;
                            GameScene::Scene->MailComposeParcelDialog->CalculatePostage();

                            return;
                        }
                    }
                    break;
                #pragma endregion
            }

            return;
        }

        if (getItem() != nullptr)
        {
            GameScene::SelectedCell = this;
        }
    }

    void MirItemCell::PlayItemSound()
    {
        if (getItem() == nullptr)
        {
            return;
        }

        switch (getItem()->Info->Type)
        {
            case ItemType::Weapon:
                SoundManager::PlaySound(SoundList::ClickWeapon);
                break;
            case ItemType::Armour:
                SoundManager::PlaySound(SoundList::ClickArmour);
                break;
            case ItemType::Helmet:
                SoundManager::PlaySound(SoundList::ClickHelmet);
                break;
            case ItemType::Necklace:
                SoundManager::PlaySound(SoundList::ClickNecklace);
                break;
            case ItemType::Bracelet:
                SoundManager::PlaySound(SoundList::ClickBracelet);
                break;
            case ItemType::Ring:
                SoundManager::PlaySound(SoundList::ClickRing);
                break;
            case ItemType::Boots:
                SoundManager::PlaySound(SoundList::ClickBoots);
                break;
            case ItemType::Potion:
                SoundManager::PlaySound(SoundList::ClickDrug);
                break;
            default:
                SoundManager::PlaySound(SoundList::ClickItem);
                break;
        }
    }

    int MirItemCell::FreeSpace()
    {
        int count = 0;

        for (int i = 0; i < getItemArray().size(); i++)
        {
            if (getItemArray()[i] == nullptr)
            {
                count++;
            }
        }

        return count;
    }

    bool MirItemCell::CanRemoveItem(UserItem *i)
    {
        if (MapObject::User->RidingMount && i->Info->Type != ItemType::Torch)
        {
            return false;
        }
        //stuck
        return FreeSpace() > 0;
    }

    bool MirItemCell::CorrectSlot(UserItem *i)
    {
        ItemType type = i->Info->Type;

        switch (static_cast<EquipmentSlot>(getItemSlot()))
        {
            case EquipmentSlot::Weapon:
                return type == ItemType::Weapon;
            case EquipmentSlot::Armour:
                return type == ItemType::Armour;
            case EquipmentSlot::Helmet:
                return type == ItemType::Helmet;
            case EquipmentSlot::Torch:
                return type == ItemType::Torch;
            case EquipmentSlot::Necklace:
                return type == ItemType::Necklace;
            case EquipmentSlot::BraceletL:
                return i->Info->Type == ItemType::Bracelet;
            case EquipmentSlot::BraceletR:
                return i->Info->Type == ItemType::Bracelet || i->Info->Type == ItemType::Amulet;
            case EquipmentSlot::RingL:
            case EquipmentSlot::RingR:
                return type == ItemType::Ring;
            case EquipmentSlot::Amulet:
                return type == ItemType::Amulet; // && i.Info.Shape > 0;
            case EquipmentSlot::Boots:
                return type == ItemType::Boots;
            case EquipmentSlot::Belt:
                return type == ItemType::Belt;
            case EquipmentSlot::Stone:
                return type == ItemType::Stone;
            case EquipmentSlot::Mount:
                return type == ItemType::Mount;
            default:
                return false;
        }

    }

    bool MirItemCell::CanUseItem()
    {
        if (getItem() == nullptr)
        {
            return false;
        }

        switch (MapObject::User->Gender)
        {
            case MirGender::Male:
                if (!getItem()->Info->RequiredGender::HasFlag(RequiredGender::Male))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::NotFemale, ChatType::System);
                    return false;
                }
                break;
            case MirGender::Female:
                if (!getItem()->Info->RequiredGender::HasFlag(RequiredGender::Female))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::NotMale, ChatType::System);
                    return false;
                }
                break;
        }

        switch (MapObject::User->Class)
        {
            case MirClass::Warrior:
                if (!getItem()->Info->RequiredClass::HasFlag(RequiredClass::Warrior))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Warriors cannot use this item.", ChatType::System);
                    return false;
                }
                break;
            case MirClass::Wizard:
                if (!getItem()->Info->RequiredClass::HasFlag(RequiredClass::Wizard))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Wizards cannot use this item.", ChatType::System);
                    return false;
                }
                break;
            case MirClass::Taoist:
                if (!getItem()->Info->RequiredClass::HasFlag(RequiredClass::Taoist))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Taoists cannot use this item.", ChatType::System);
                    return false;
                }
                break;
            case MirClass::Assassin:
                if (!getItem()->Info->RequiredClass::HasFlag(RequiredClass::Assassin))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Assassins cannot use this item.", ChatType::System);
                    return false;
                }
                break;
            case MirClass::Archer:
                if (!getItem()->Info->RequiredClass::HasFlag(RequiredClass::Archer))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Archers cannot use this item.", ChatType::System);
                    return false;
                }
                break;
        }

        switch (getItem()->Info->RequiredType)
        {
            case RequiredType::Level:
                if (MapObject::User->Level < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::LowLevel, ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxAC:
                if (MapObject::User->Stats[Stat::MaxAC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough AC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxMAC:
                if (MapObject::User->Stats[Stat::MaxMAC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough MAC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxDC:
                if (MapObject::User->Stats[Stat::MaxDC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::LowDC, ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxMC:
                if (MapObject::User->Stats[Stat::MaxMC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::LowMC, ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxSC:
                if (MapObject::User->Stats[Stat::MaxSC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::LowSC, ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxLevel:
                if (MapObject::User->Level > getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You have exceeded the maximum level.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinAC:
                if (MapObject::User->Stats[Stat::MinAC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base AC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinMAC:
                if (MapObject::User->Stats[Stat::MinMAC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base MAC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinDC:
                if (MapObject::User->Stats[Stat::MinDC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base DC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinMC:
                if (MapObject::User->Stats[Stat::MinMC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base MC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinSC:
                if (MapObject::User->Stats[Stat::MinSC] < getItem()->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base SC.", ChatType::System);
                    return false;
                }
                break;
        }

        switch (getItem()->Info->Type)
        {
            case ItemType::Saddle:
            case ItemType::Ribbon:
            case ItemType::Bells:
            case ItemType::Mask:
            case ItemType::Reins:
                if (MapObject::User->Equipment[static_cast<int>(EquipmentSlot::Mount)] == nullptr)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have a mount equipped.", ChatType::System);
                    return false;
                }
                break;
            case ItemType::Hook:
            case ItemType::Float:
            case ItemType::Bait:
            case ItemType::Finder:
            case ItemType::Reel:
                if (MapObject::User->Equipment[static_cast<int>(EquipmentSlot::Weapon)] == nullptr || !MapObject::User->Equipment[static_cast<int>(EquipmentSlot::Weapon)]->Info.isFishingRod())
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have a fishing rod equipped.", ChatType::System);
                    return false;
                }
                break;
        }
        return true;
    }

    bool MirItemCell::CanWearItem(UserItem *i)
    {
        if (i == nullptr)
        {
            return false;
        }

        //If Can remove;

        switch (MapObject::User->Gender)
        {
            case MirGender::Male:
                if (!i->Info->RequiredGender::HasFlag(RequiredGender::Male))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::NotFemale, ChatType::System);
                    return false;
                }
                break;
            case MirGender::Female:
                if (!i->Info->RequiredGender::HasFlag(RequiredGender::Female))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::NotMale, ChatType::System);
                    return false;
                }
                break;
        }

        switch (MapObject::User->Class)
        {
            case MirClass::Warrior:
                if (!i->Info->RequiredClass::HasFlag(RequiredClass::Warrior))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Warriors cannot use this item.", ChatType::System);
                    return false;
                }
                break;
            case MirClass::Wizard:
                if (!i->Info->RequiredClass::HasFlag(RequiredClass::Wizard))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Wizards cannot use this item.", ChatType::System);
                    return false;
                }
                break;
            case MirClass::Taoist:
                if (!i->Info->RequiredClass::HasFlag(RequiredClass::Taoist))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Taoists cannot use this item.", ChatType::System);
                    return false;
                }
                break;
            case MirClass::Assassin:
                if (!i->Info->RequiredClass::HasFlag(RequiredClass::Assassin))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Assassins cannot use this item.", ChatType::System);
                    return false;
                }
                break;
            case MirClass::Archer:
                if (!i->Info->RequiredClass::HasFlag(RequiredClass::Archer))
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("Archers cannot use this item.", ChatType::System);
                    return false;
                }
                break;
        }

        switch (i->Info->RequiredType)
        {
            case RequiredType::Level:
                if (MapObject::User->Level < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::LowLevel, ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxAC:
                if (MapObject::User->Stats[Stat::MaxAC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough AC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxMAC:
                if (MapObject::User->Stats[Stat::MaxMAC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough MAC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxDC:
                if (MapObject::User->Stats[Stat::MaxDC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::LowDC, ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxMC:
                if (MapObject::User->Stats[Stat::MaxMC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::LowMC, ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxSC:
                if (MapObject::User->Stats[Stat::MaxSC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::LowSC, ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MaxLevel:
                if (MapObject::User->Level > i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You have exceeded the maximum level.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinAC:
                if (MapObject::User->Stats[Stat::MinAC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base AC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinMAC:
                if (MapObject::User->Stats[Stat::MinMAC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base MAC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinDC:
                if (MapObject::User->Stats[Stat::MinDC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base DC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinMC:
                if (MapObject::User->Stats[Stat::MinMC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base MC.", ChatType::System);
                    return false;
                }
                break;
            case RequiredType::MinSC:
                if (MapObject::User->Stats[Stat::MinSC] < i->Info->RequiredAmount)
                {
                    GameScene::Scene->ChatDialog->ReceiveChat("You do not have enough Base SC.", ChatType::System);
                    return false;
                }
                break;
        }

        if (i->Info->Type == ItemType::Weapon || i->Info->Type == ItemType::Torch)
        {
            if (i->getWeight() - (getItem() != nullptr ? getItem()->getWeight() : 0) + MapObject::User->CurrentHandWeight > MapObject::User->Stats[Stat::HandWeight])
            {
                GameScene::Scene->ChatDialog->ReceiveChat(GameLanguage::TooHeavyToHold, ChatType::System);
                return false;
            }
        }
        else
        {
            if (i->getWeight() - (getItem() != nullptr ? getItem()->getWeight() : 0) + MapObject::User->CurrentWearWeight > MapObject::User->Stats[Stat::WearWeight])
            {
                GameScene::Scene->ChatDialog->ReceiveChat("It is too heavy to wear.", ChatType::System);
                return false;
            }
        }

        switch (i->Info->Type)
        {
            case ItemType::Bait:
            case ItemType::Finder:
            case ItemType::Hook:
            case ItemType::Reel:
            case ItemType::Float:
                if (!GameScene::getUser()->getHasFishingRod())
                {
                    return false;
                }
                break;
            case ItemType::Bells:
            case ItemType::Reins:
            case ItemType::Ribbon:
            case ItemType::Saddle:
                if (GameScene::getUser()->MountType < 0)
                {
                    return false;
                }
                break;
            case ItemType::Socket:
                if (GameScene::SelectedItem == nullptr || GameScene::SelectedItem->Info->Type == ItemType::Mount || (GameScene::SelectedItem->Info->Type == ItemType::Weapon && GameScene::SelectedItem->Info->isFishingRod()))
                {
                    return false;
                }
                break;
        }

        return true;
    }

    void MirItemCell::DrawControl()
    {
        if (getItem() != nullptr && GameScene::SelectedCell != this && getLocked() != true)
        {
            CreateDisposeLabel();

            if (getLibrary() != nullptr)
            {
                unsigned short image = getItem()->getImage();

                Size *imgSize = getLibrary()->GetTrueSize(image);

                Point *offSet = new Point((getSize()->Width - imgSize->Width) / 2, (getSize()->Height - imgSize->Height) / 2);

                if (getGridType() == MirGridType::Craft)
                {
                    Point tempVar(-2, -1);
                    Libraries::Prguse->Draw(1121, Functions::Add(getDisplayLocation(), &tempVar), Color::White, getUseOffSet(), 0.8F);
                }

                getLibrary()->Draw(image, Functions::Add(getDisplayLocation(), offSet), getForeColour(), getUseOffSet(), 1.0F);

//C# TO C++ CONVERTER TODO TASK: A 'delete offSet' statement was not added since offSet was passed to a method or constructor. Handle memory management manually.
            }
        }
        else if (getItem() != nullptr && (GameScene::SelectedCell == this || getLocked()))
        {
            CreateDisposeLabel();

            if (getLibrary() != nullptr)
            {
                unsigned short image = getItem()->getImage();

                Size *imgSize = getLibrary()->GetTrueSize(image);

                Point *offSet = new Point((getSize()->Width - imgSize->Width) / 2, (getSize()->Height - imgSize->Height) / 2);

                getLibrary()->Draw(image, Functions::Add(getDisplayLocation(), offSet), Color::DimGray, getUseOffSet(), 0.8F);

//C# TO C++ CONVERTER TODO TASK: A 'delete offSet' statement was not added since offSet was passed to a method or constructor. Handle memory management manually.
            }
        }
        else if (getShadowItem() != nullptr)
        {
            CreateDisposeLabel();

            if (getLibrary() != nullptr)
            {
                unsigned short image = getShadowItem()->Info->Image;

                Size *imgSize = getLibrary()->GetTrueSize(image);

                Point *offSet = new Point((getSize()->Width - imgSize->Width) / 2, (getSize()->Height - imgSize->Height) / 2);

                if (getGridType() == MirGridType::Craft)
                {
                    Point tempVar2(-2, -1);
                    Libraries::Prguse->Draw(1121, Functions::Add(getDisplayLocation(), &tempVar2), Color::White, getUseOffSet(), 0.8F);
                }

                getLibrary()->Draw(image, Functions::Add(getDisplayLocation(), offSet), Color::DimGray, getUseOffSet(), 0.8F);

//C# TO C++ CONVERTER TODO TASK: A 'delete offSet' statement was not added since offSet was passed to a method or constructor. Handle memory management manually.
            }
        }
        else
        {
            DisposeCountLabel();
        }
    }

    void MirItemCell::OnMouseEnter()
    {
        MirImageControl::OnMouseEnter();
        if (getGridType() == MirGridType::Inspect)
        {
            GameScene::Scene->CreateItemLabel(getItem(), true);
        }
        else
        {
            if (getItem() != nullptr)
            {
                GameScene::Scene->CreateItemLabel(getItem());
            }
            else if (getShadowItem() != nullptr)
            {
                GameScene::Scene->CreateItemLabel(getShadowItem(), false, getShadowItem()->CurrentDura == getShadowItem()->MaxDura);
            }
        }
    }

    void MirItemCell::OnMouseLeave()
    {
        MirImageControl::OnMouseLeave();
        GameScene::Scene->DisposeItemLabel();
        GameScene::HoverItem = nullptr;
    }

    void MirItemCell::CreateDisposeLabel()
    {
        if (getItem() == nullptr && getShadowItem() == nullptr)
        {
            return;
        }

        if (getItem() != nullptr && getShadowItem() == nullptr && getItem()->Info->StackSize <= 1)
        {
            DisposeCountLabel();
            return;
        }

        if (getCountLabel() == nullptr || getCountLabel()->isDisposed())
        {
            MirLabel tempVar();
            setCountLabel(&tempVar);
            getCountLabel()->setAutoSize(true);
            getCountLabel()->setForeColour(Color::Yellow);
            getCountLabel()->setNotControl(true);
            getCountLabel()->setOutLine(false);
            getCountLabel()->setParent(this);
        }

        if (getShadowItem() != nullptr)
        {
            getCountLabel()->setForeColour((getItem() == nullptr || getShadowItem()->Count > getItem()->Count) ? Color::Red : Color::LimeGreen);
            getCountLabel()->setText(StringHelper::formatSimple("{0}/{1}", getItem() == nullptr ? 0 : getItem()->Count, getShadowItem()->Count));
        }
        else
        {
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
            getCountLabel()->setText(getItem()->Count.ToString("###0"));
        }

        Point tempVar2(getSize()->Width - getCountLabel()->getSize()->Width, getSize()->Height - getCountLabel()->getSize()->Height);
        getCountLabel()->setLocation(&tempVar2);
    }

    void MirItemCell::DisposeCountLabel()
    {
        if (getCountLabel() != nullptr && !getCountLabel()->isDisposed())
        {
            getCountLabel()->Dispose();
        }
        setCountLabel(nullptr);
    }
}
